package com.qisu.command;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Component;

import com.qisu.converters.Converters;

import io.netty.channel.ChannelHandlerContext;

/**
 * 告警信息
 * @author li
 *
 */
@Component
public class CMD108 extends AbstractSinexcelCmd {

	@PostConstruct
	@Override
	protected void init() {
		super.init();

		fieldsList.addField(new CommandFieldDef<Integer>(2))
				.addField(new CommandFieldDef<Integer>(2))
				.addField(new CommandFieldDef<String>(32, Converters.strConverter, "充电桩ID"))
				.addField(new CommandFieldDef<Integer>(32, Converters.intConverter, "告警位信息"));
	}

	@Override
	protected void processCmd(ChannelHandlerContext ctx, byte[] req) {
		String pileSerial = fieldsList.getValue("充电桩ID");
		int faultInfo = fieldsList.getValue("告警位信息");
		/*HashMap<String, Object> packetData = new HashMap<String, Object>() {
			private static final long serialVersionUID = 3653368819157051846L;

			{
				put("充电桩ID", fieldsList.getValue("充电桩ID"));
				put("告警位信息", fieldsList.getValue("告警位信息"));
			}
		};*/

		
		if (faultInfo !=0) { //0 无告警
//			_pile.insertPileFault(pileSerial, faultInfo);
			log.warn(" ===== 充电桩{}, 告警代码 : {} =====",pileSerial,faultInfo);
		}
		
	}

	@Override
	protected void responseClient(ChannelHandlerContext ctx) {
		

	}

}
